#include "mm.h"
#include <fcntl.h>
#include <unistd.h>
#include <minix/callnr.h>
#include <minix/com.h>
#include "param.h"
#include <mouse/mouse.h>

FORWARD _PROTOTYPE( int do_ms_get, (void));
FORWARD _PROTOTYPE( int do_ms_put, (void));

struct mouse_status mouse_status;



PUBLIC int do_ms_cmd()
{
	int command = mm_in.m1_i1;

	switch(command)
	{
		case MS_GET_DATA: do_ms_get(); break;
		case MS_PUT_DATA: do_ms_put(); break;
		default: panic("do_ms_cmd() error", NO_NUM); break;
	}

	return (OK);
}

PRIVATE int do_ms_get(void)
{
	int iRetVal;

	iRetVal = sys_copy(0, D, (phys_bytes) &mouse_status, mm_in.m_source,
		D,(phys_bytes) mm_in.m1_p1, mm_in.m1_i2);

	return(OK);
} 


PRIVATE int do_ms_put(void)
{
	mouse_status.x = mm_in.m1_i2;
	mouse_status.y = mm_in.m1_i3;
	mouse_status.left_button = (int) mm_in.m1_p1;
	mouse_status.right_button = (int) mm_in.m1_p2;

	dont_reply = TRUE;
	return(OK);
}
 
